import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

//
import path from "path";
//
import ElementPlus from "unplugin-element-plus/vite";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";

// https://vite.dev/config/
export default defineConfig(({ command, mode }) => {
    return {
        base: "./",
        //
        plugins: [
            vue(),
            ElementPlus(),
            AutoImport({
                resolvers: [ElementPlusResolver()],
            }),
            Components({
                resolvers: [ElementPlusResolver()],
            }),
        ],
        // 解析配置 https://vitejs.cn/vite3-cn/config/shared-options.html#resolve-alias
        resolve: {
            alias: {
                "@": path.resolve(__dirname, "./src"), //import时直接将 @ 当作src目录进行解析
            },
        },

        // 开发模式服务器配置 https://vitejs.cn/vite3-cn/config/server-options.html
        server: {
            hmr: true, // 热更新 关闭 避免每次修改浏览器刷新
            strictPort: true, // * 固定端口(如果端口被占用则中止)
            host: "0.0.0.0", // 设置host 可以在局域网内访问
            port: 19966, // 服务启动端口
        },
    };
});
